<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use PDOStatement;

class ElectricChargingScheme extends Model
{
    protected $connection="mysql_center";
    protected $table="electric_charging_scheme";
    public function __construct(array $attributes = [])
    {
        DB::connection('mysql_center')->enableQueryLog();
        parent::__construct($attributes);
    }
    //
    /**
     * 根据条件查询方案
     * @param string $fields
     * @param string $where
     * @return array|PDOStatement|string|Model|null
     */
    public static function getSchemeByWhere($where = '', $fields = '*')
    {
        $db = self::select(DB::raw($fields));
        $where != '' && $db->where($where);
        $data = $db->first();
        if ($data->count()) {
            $data = $data->toArray();
        } else {
            $data = [];
        }
        return $data;
    }
}
